$(function () {
    $("#jqGrid").Grid({
        url: '../tragettable/list',
        colModel: [
            {
                label: 'id',
                name: 'id',
                index: 'id',
                key: true,
                hidden: true
            },
            {
                label: '表名',
                name: 'tableId',
                index: 'table_id',
                width: 80
            },
            {
                label: '数据日期YYYYMMDD',
                name: 'dataDt',
                index: 'data_dt',
                width: 80
            },
            {
                label: '行号',
                name: 'rowNo',
                index: 'row_no',
                width: 80
            },
            {
                label: '列编号',
                name: 'colSeqNo',
                index: 'col_seq_no',
                width: 80
            },
            {
                label: '老数据',
                name: 'oldData',
                index: 'old_data',
                width: 80
            },
            {
                label: '新数据',
                name: 'newData',
                index: 'new_data',
                width: 80
            },
            {
                label: '检查结果',
                name: 'checkResult',
                index: 'check_result',
                width: 80
            },
            {
                label: '更新时间',
                name: 'updateTime',
                index: 'update_time',
                width: 80
            },
            {
                label: '状态0-正常1-删除',
                name: 'state',
                index: 'state',
                width: 80
            }]
    });
});

let vm = new Vue({
    el: '#rrapp',
    data: {
        showList: true,
        title: null,
        tragetTable: {},
        ruleValidate: {
            name: [
                {required: true, message: '名称不能为空', trigger: 'blur'}
            ]
        },
        q: {
            name: ''
        }
    },
    methods: {
        query: function () {
            vm.reload();
        }
        ,
        add: function () {
            vm.showList = false;
            vm.title = "新增";
            vm.tragetTable = {};
        }
        ,
        update: function (event) {
            id = getSelectedRow("#jqGrid");
            id ==
            null
        )
{
    return;
}
vm.showList = false;
vm.title = "修改";

vm.getInfo(id)
},
saveOrUpdate: function (event) {
    let url = vm
        .tragetTable.id ==
    null ? "../tragettable/save" : "../tragettable/update";
    Ajax.request({
        url: url,
        params: JSON.stringify(vm.tragetTable),
        type: "POST",
        contentType: "application/json",
        successCallback: function (r) {
            alert('操作成功', function (index) {
                vm.reload();
            });
        }
    });
}
,
del: function (event) {
    id = getSelectedRows("#jqGrid");
    ids == null
)
{
    return;
}

confirm('确定要删除选中的记录？', function () {
    Ajax.request({
        url: "../tragettable/delete",
        params: JSON.stringify(ids),
        type: "POST",
        contentType: "application/json",
        successCallback: function () {
            alert('操作成功', function (index) {
                vm.reload();
            });
        }
    });
});
},
getInfo: function (id) {
    Ajax.request({
            tragettable / info /
        "+id,
    async: true,
        successCallback
:

    function (r) {
        tragetTable = r.tragetTable;
    }
})
    ;
}
,
reload: function (event) {
    vm.showList = true;
    let page = $("#jqGrid").jqGrid('getGridParam', 'page');
    $("#jqGrid").jqGrid('setGridParam', {
        postData: {'name': vm.q.name},
        page: page
    }).trigger("reloadGrid");
    vm.handleReset('formValidate');
}
,
reloadSearch: function () {
    vm.q = {
        name: ''
    }
    vm.reload();
}
,
handleSubmit: function (name) {
    handleSubmitValidate(this, name, function () {
        vm.saveOrUpdate()
    });
}
,
handleReset: function (name) {
    handleResetForm(this, name);
}
}
})
;